package com.vitaf.cash.app.ui.activity

import android.view.View
import com.vitaf.cash.app.R
import com.vitaf.cash.app.common.VitafComAct
import com.vitaf.cash.app.databinding.VitafActUserAdviceTypePageBinding
import com.vitaf.cash.app.event.VitafEventPointType
import com.vitaf.cash.app.utils.VitafTitleBarUtil
import com.vitaf.cash.app.utils.helper.VitafConfigsHp
import com.vitaf.cash.lib.adapter.VitafOnSingleClickListener
import java.util.Calendar

/**
 * 建议类型
 */
class VitafUserAdviceTypeAct: VitafComAct() {
    lateinit var binding: VitafActUserAdviceTypePageBinding

    override fun createVitafContentView(): View {
        binding = VitafActUserAdviceTypePageBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun initializeVitafViews() {
        getTitleBarManager().setVisibility(View.VISIBLE)
        getTitleBarManager().setTitle(getString(R.string.gombe_credit_string_customer_dialog_feedback))
        getTitleBarManager().setTitleColor(getColor(R.color.black))
        getTitleBarManager().setRightButtonIcon(R.mipmap.gombe_credit_image_customer_black_icon)
        getTitleBarManager().setBackButtonIcon(R.mipmap.gombe_credit_image_back_black_icon)
        getTitleBarManager().setRootBackgroundColor(getColor(R.color.white))
        VitafTitleBarUtil.setStatusBarLightMode(this, true)
    }

    override fun setupVitafEventListeners() {
        //联系客服
        setRightButtonClickListener(object : VitafOnSingleClickListener(){
            override fun onSingleClick(v: View?) {
                showCustomerDialog("Advice Type Page")
                addEventPointRequestAction(VitafEventPointType.GOMBECREDIT_TRACK_CLICK.CUSTOMER,"Advice Type Page")
            }
        })
        //意见反馈
        binding.feedbackLayout.setOnClickListener(object : VitafOnSingleClickListener(){
            override fun onSingleClick(v: View?) {
                onIntent(VitafUserFeedbackAct::class.java)
            }
        })
        //在线客服
        binding.onlineLayout.setOnClickListener(object : VitafOnSingleClickListener(){
            override fun onSingleClick(v: View?) {
                onIntent(VitafUserChatAct::class.java)
            }
        })
    }

    override fun loadVitafData() {
        val hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY)
        when (hour) {
            in 0..11 -> {
                binding.textHello.text = getString(R.string.gombe_credit_advice_type_morning)
            }
            in 12..17 -> {
                binding.textHello.text = getString(R.string.gombe_credit_advice_type_afternoon)
            }
            else -> {
                binding.textHello.text = getString(R.string.gombe_credit_advice_type_evening)
            }
        }

        //是否显示在线客服入口
        val isShowCustomerChat = VitafConfigsHp.isShowCustomerChat()
        if (isShowCustomerChat){
            binding.onlineLayout.visibility = View.VISIBLE
        } else {
            binding.onlineLayout.visibility = View.GONE
        }
    }

    override fun onStart() {
        super.onStart()
        addEventPointRequestAction(VitafEventPointType.GOMBECREDIT_TRACK_PAGE.USER_ADVICE_TYPE_START)
    }

    override fun onDestroy() {
        super.onDestroy()
        addEventPointRequestAction(VitafEventPointType.GOMBECREDIT_TRACK_PAGE.USER_ADVICE_TYPE_END)
    }
}